/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package services;

import java.util.List;
import javax.persistence.EntityManager;
import services.interfaces.IQuestionService;
import javax.persistence.PersistenceContext;
import javax.validation.ConstraintDeclarationException;
import javax.validation.ConstraintViolationException;
import models.Comments;
import models.Questions;
import models.Users;

/**
 *
 * @author milokokok
 */
public class QuestionServiceImpl extends GenericServiceImpl<Questions> implements IQuestionService{

    
    @PersistenceContext(unitName="ors-ejbPU2")
    private EntityManager em;
    
    public QuestionServiceImpl() {
        super(Questions.class);
    }
    
    
    @Override
    public Questions getUserQuestion(Users user) {
        return (Questions)em.createQuery("Questions.getUserQuestion").setParameter("id_user", user.getId()).getResultList();
    }

    /*@Override
    public List<Comments> getCommentsList(Users author) {
        return null;
    }*/

    @Override
    protected EntityManager getEntityManager() {
       return  em;
    }

    @Override
    public int count() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}